﻿@{
    ViewBag.Title = "背景图片";
    Layout = "~/Views/Shared/_adminLayout.cshtml";
    List<Wx_TemplateImageType> typeList = ViewBag.typeList;
}

@model Pagination<Wx_TemplateImage>

<h2 class="sub-header">背景列表</h2>
<div>
    @Html.ActionLink("新增背景图片", "TemplateImageEdit", null, new { Class = "btn btn-primary" })
</div>
<hr />
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover table-condensed">
        <thead>
            <tr>
                <th>#</th>
                <th>分类</th>
                <th>图片</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.CheckBox("ImgId", false, new { value = @item.ImgId })
                    </td>
                    <td>

                        @if (typeList.Exists(p => p.TypeId == item.TypeId))
                        {
                            @typeList.Find(p => p.TypeId == item.TypeId).TypeName
                        }
                        else
                        {
                            @item.TypeId
                        }
                    </td>
                    <td>
                        @if (!string.IsNullOrEmpty(item.ImgSrc))
                        {
                            <img src="@Url.Content("~/images/qrcodeBg/")@item.ImgSrc" height="35" />
                        }
                    </td>
                    <td>
                        @Html.ActionLink("修改", "TemplateImageEdit", new { id = @item.ImgId }, new { Class = "btn btn-default" })
                        @using (Html.BeginForm("TemplateImageDelete", "Qrcode", new { id = @item.ImgId }, FormMethod.Post, new { onsubmit = "return marksure();", style = "display:inline-block" }))
                        {
                            <input type="submit" class="btn btn-default" value="Delete" />
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
<nav>
    <ul class="pagination">
        <li>
            @Html.ActionLink("<<", "TemplateImage", new { page = 0 })
        </li>
        @for (int i = 0; i < Model.TotalPages; i++)
        {
            if (i == Model.PageIndex)
            {
                <li class="active">
                    @Html.ActionLink((i + 1).ToString(), "TemplateImage", new { page = i })
                </li>
            }
            else
            {
                <li>
                    @Html.ActionLink((i + 1).ToString(), "TemplateImage", new { page = i })
                </li>
            }
        }
        <li>
            @Html.ActionLink(">>", "TemplateImage", new { page = Model.TotalPages - 1 > 0 ? Model.TotalPages - 1 : 0 })
        </li>
    </ul>
</nav>

